package com.edu.exam.enums;

import com.edu.exam.enums.core.BaseEnum;

/**
 * 巡查任务安全级别枚举
 *
 * @author System
 * @version 1.0.0
 */
public enum PatrolTaskSafetyLevel implements BaseEnum {
    LOW("低风险", "低安全级别"),
    NORMAL("一般", "一般安全级别"),
    MEDIUM("中等", "中等安全级别"),
    HIGH("高风险", "高安全级别"),
    CRITICAL("极高风险", "极高安全级别");

    private final String code;
    private final String description;

    PatrolTaskSafetyLevel(String code, String description) {
        this.code = code;
        this.description = description;
    }

    @Override
    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static PatrolTaskSafetyLevel fromCode(String code) {
        for (PatrolTaskSafetyLevel level : values()) {
            if (level.getCode().equals(code)) {
                return level;
            }
        }
        throw new IllegalArgumentException("无效的安全级别代码: " + code);
    }

    public static PatrolTaskSafetyLevel fromDescription(String description) {
        for (PatrolTaskSafetyLevel level : values()) {
            if (level.getDescription().equals(description)) {
                return level;
            }
        }
        throw new IllegalArgumentException("无效的安全级别描述: " + description);
    }

    @Override
    public String toString() {
        return description;
    }
}